package com.dragon.modules.yuegou.client.wechat_mini.client.impl;

import com.dragon.modules.yuegou.client.wechat_mini.client.SecurityClient;
import com.dragon.modules.yuegou.client.wechat_mini.common.BaseResponse;
import com.dragon.modules.yuegou.client.wechat_mini.conn.IMiniClient;
import com.dragon.modules.yuegou.client.wechat_mini.request.MediaCheckAsyncRequest;
import com.dragon.modules.yuegou.client.wechat_mini.response.MediaCheckAsyncResponse;

import java.io.File;
import java.util.HashMap;
import java.util.Map;

public class SecurityClientImpl implements SecurityClient {
	
	private final IMiniClient client;

	public SecurityClientImpl(IMiniClient client) {
		this.client = client;
	}
	
	@Override
	public BaseResponse imgSecCheck(String accessToken, File file) {
		return client.post("/wxa/img_sec_check")
				.accessToken(accessToken)
				.media(file)
				.execute(BaseResponse.class);
	}

	@Override
	public MediaCheckAsyncResponse mediaCheckAsync(String accessToken, MediaCheckAsyncRequest request) {
		return client.post("/wxa/media_check_async")
				.accessToken(accessToken)
				.json(request)
				.execute(MediaCheckAsyncResponse.class);
	}

	@Override
	public BaseResponse msgSecCheck(String accessToken, String content) {
		Map<String, String> request = new HashMap<>();
		request.put("content", content);
		return client.post("/wxa/msg_sec_check")
				.accessToken(accessToken)
				.json(request)
				.execute(BaseResponse.class);
	}

}
